package com.example.demo.controller;

import com.example.demo.service.OrderService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class OrderController {
	
	@Autowired
	private OrderService orderServiceImpl;

	//仅供测试使用 正常使用则是加入到gateway中
	@RequestMapping("/list")
	@HystrixCommand(fallbackMethod = "getDefaultUser")
	public List<String> getOrderList() {
		return orderServiceImpl.getOrderMemberr();
	}

	public List<String> getDefaultUser() {
		System.out.println("熔断，默认回调函数");
		return new ArrayList();
	}

	@RequestMapping("/list1")
	public String getOrderList1() {
		return "hello";
	}
}
